home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / python-gnome2-desktop / examples / gnomeprint / example_03.py < prev    next >
Encoding:
Python Source  |  2009-03-14  |  1.5 KB  |  61 lines

  1. #! /usr/bin/env python
  2.  
  3. # *  example_03.c: sample gnome-print code
  4. # *
  5. # *  This program is free software; you can redistribute it and/or
  6. # *  modify it under the terms of the GNU Library General Public License
  7. # *  as published by the Free Software Foundation; either version 2 of
  8. # *  the License, or (at your option) any later version.
  9. # *
  10. # *  This program is distributed in the hope that it will be useful,
  11. # *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # *  GNU Library General Public License for more details.
  14. # *
  15. # *  You should have received a copy of the GNU Library General Public
  16. # *  License along with this program; if not, write to the Free Software
  17. # *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. # *
  19. # *  Authors:
  20. # *    Chema Celorio <chema@ximian.com>
  21. #    Python conversion:
  22. #      Gustavo J. A. M. Carneiro <gustavo@users.sf.net>
  23. # *
  24. # *  Copyright (C) 2002 Ximian Inc. and authors
  25. # *
  26. # */
  27.  
  28. #/*
  29. # * See README
  30. # */
  31.  
  32. import pygtk; pygtk.require("2.0")
  33. import gnomeprint
  34.  
  35.  
  36. def my_draw(gpc):
  37.     font = gnomeprint.font_find_closest("Helvetica", 12)
  38.     
  39.     gpc.beginpage("1")
  40.     gpc.setfont(font)
  41.     
  42.     for i in xrange(100):
  43.     gpc.moveto(100, 100)
  44.     gpc.show("This is example_03.py which uses GnomeFont\n")
  45.     
  46.     gpc.showpage()
  47.  
  48.  
  49. def my_print():
  50.     job = gnomeprint.Job(gnomeprint.config_default())
  51.     gpc = job.get_context()
  52.  
  53.     my_draw(gpc)
  54.  
  55.     job.close()
  56.     job.print_()
  57.  
  58. my_print()
  59. print "Done..."
  60.  
  61.